package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	import gs.events.TweenEvent;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.tree.AbstractLayoutCache;
	
	public class FrameBattleSetting extends JFrame
	{
		//members define
		private var panelTop:JPanel;
		private var panelTabs:JPanel;
		private var btn_battle_setting_tab_char:JToggleButton;
		private var btn_battle_setting_tab_slave:JToggleButton;
		private var btn_battle_setting_tab_lover:JToggleButton;
		private var btn_battle_setting_tab_pet:JToggleButton;
		private var btn_battle_setting_tab_team:JToggleButton;
		private var comboItems:JComboBox;
		private var labelOperation:JLabel;
		private var labelInfo:JLabel;
		private var panelOperations:JPanel;
		private var labelOperationSoul:JLabel;
		private var panelOperationsSoul:JPanel;
		private var labelSkills:JLabel;
		private var panelSkillsBase:JPanel;
		private var panelSkillsControl:JPanel;
		private var panelSkillsAttack:JPanel;
		private var panelSkillsAssist:JPanel;
		private var panel68:JPanel;
		private var btn_battle_setting_cancel:JButton;
		private var btn_battle_setting_apply:JButton;
		private var btn_battle_setting_advanced:JButton;
		
		
		private var btn_close:JButton;
		private var _panelsOperation:Array = new Array();
		private var _panelsOperationSoul:Array = new Array();
		private var _panelsSkillsBase:Array = new Array();
		private var _panelsSkillsControl:Array = new Array();
		private var _panelsSkillsAttack:Array = new Array();
		private var _panelsSkillsAssist:Array = new Array();
		
		private var arAutoBattleSkills:Array = new Array();
		private var arAutoBattleSkillsSoul:Array = new Array();
		
		public function FrameBattleSetting()
		{
			
			//component creation
			setResizable(false);
			setBackgroundDecorator(null);
			setBorder(new EmptyBorder());
			this.setClipMasked(false);
			getContentPane().setClipMasked(false);
			getTitleBar().getFrame().setClipMasked(false);
			
			btn_close = new JButton();
			btn_close.setLocation(new IntPoint(198, 0));
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			this.getTitleBar().setCloseButton(btn_close);
			
			//component creation
			setSize(new IntDimension(295, 422));
			setPreferredSize(new IntDimension(295, 422));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panelTop = new JPanel();
			panelTop.setLocation(new IntPoint(0, 0));
			panelTop.setSize(new IntDimension(295, 33));
			panelTop.setPreferredSize(new IntDimension(295, 33));
			var layout1:EmptyLayout = new EmptyLayout();
			panelTop.setLayout(layout1);
			
			panelTabs = new JPanel();
			panelTabs.setLocation(new IntPoint(9, 2));
			panelTabs.setSize(new IntDimension(275, 25));
			var layout2:FlowLayout = new FlowLayout();
			layout2.setAlignment(AsWingConstants.CENTER);
			layout2.setHgap(0);
			layout2.setVgap(0);
			layout2.setMargin(false);
			panelTabs.setLayout(layout2);
			
			btn_battle_setting_tab_char = new JToggleButton();
			btn_battle_setting_tab_char.setLocation(new IntPoint(60, -10));
			btn_battle_setting_tab_char.setSize(new IntDimension(55, 25));
			btn_battle_setting_tab_char.setPreferredSize(new IntDimension(55, 25));
			btn_battle_setting_tab_char.setText("label");
			
			btn_battle_setting_tab_slave = new JToggleButton();
			btn_battle_setting_tab_slave.setLocation(new IntPoint(55, 0));
			btn_battle_setting_tab_slave.setSize(new IntDimension(55, 25));
			btn_battle_setting_tab_slave.setPreferredSize(new IntDimension(55, 25));
			btn_battle_setting_tab_slave.setText("label");
			
			btn_battle_setting_tab_lover = new JToggleButton();
			btn_battle_setting_tab_lover.setLocation(new IntPoint(112, 0));
			btn_battle_setting_tab_lover.setSize(new IntDimension(55, 25));
			btn_battle_setting_tab_lover.setPreferredSize(new IntDimension(55, 25));
			btn_battle_setting_tab_lover.setText("label");
			
			btn_battle_setting_tab_pet = new JToggleButton();
			btn_battle_setting_tab_pet.setLocation(new IntPoint(166, 0));
			btn_battle_setting_tab_pet.setSize(new IntDimension(55, 25));
			btn_battle_setting_tab_pet.setPreferredSize(new IntDimension(55, 25));
			btn_battle_setting_tab_pet.setText("label");
			
			btn_battle_setting_tab_team = new JToggleButton();
			btn_battle_setting_tab_team.setLocation(new IntPoint(224, 0));
			btn_battle_setting_tab_team.setSize(new IntDimension(55, 25));
			btn_battle_setting_tab_team.setPreferredSize(new IntDimension(55, 25));
			btn_battle_setting_tab_team.setText("label");
			
			comboItems = new JComboBox();
			comboItems.setOpaque(true);
			comboItems.setLocation(new IntPoint(173, 31));
			comboItems.setSize(new IntDimension(110, 21));
			comboItems.setPreferredSize(new IntDimension(110, 21));
			comboItems.setEditable(false);
			comboItems.setMaximumRowCount(10);
			
			labelOperation = new JLabel();
			labelOperation.setLocation(new IntPoint(21, 32));
			labelOperation.setSize(new IntDimension(148, 21));
			labelOperation.setPreferredSize(new IntDimension(148, 21));
			labelOperation.setText("操作序列");
			labelOperation.setHorizontalAlignment(AsWingConstants.LEFT);
			
			labelInfo = new JLabel();
			labelInfo.setLocation(new IntPoint(12, 64));
			labelInfo.setSize(new IntDimension(272, 20));
			labelInfo.setPreferredSize(new IntDimension(272, 20));
			labelInfo.setText("label");
			
			panelOperations = new JPanel();
			panelOperations.setLocation(new IntPoint(12, 53));
			panelOperations.setSize(new IntDimension(272, 44));
			panelOperations.setPreferredSize(new IntDimension(272, 44));
			var layout3:GridLayout = new GridLayout();
			layout3.setRows(1);
			layout3.setColumns(6);
			layout3.setHgap(2);
			layout3.setVgap(0);
			panelOperations.setLayout(layout3);
			
			labelOperationSoul = new JLabel();
			labelOperationSoul.setLocation(new IntPoint(21, 99));
			labelOperationSoul.setSize(new IntDimension(252, 21));
			labelOperationSoul.setPreferredSize(new IntDimension(252, 21));
			labelOperationSoul.setText("label");
			labelOperationSoul.setHorizontalAlignment(AsWingConstants.LEFT);
			
			panelOperationsSoul = new JPanel();
			panelOperationsSoul.setLocation(new IntPoint(12, 120));
			panelOperationsSoul.setSize(new IntDimension(272, 44));
			panelOperationsSoul.setPreferredSize(new IntDimension(272, 44));
			var layout4:GridLayout = new GridLayout();
			layout4.setRows(1);
			layout4.setColumns(6);
			layout4.setHgap(2);
			layout4.setVgap(0);
			panelOperationsSoul.setLayout(layout4);
			
			labelSkills = new JLabel();
			labelSkills.setLocation(new IntPoint(21, 166));
			labelSkills.setSize(new IntDimension(252, 21));
			labelSkills.setPreferredSize(new IntDimension(252, 21));
			labelSkills.setText("label");
			labelSkills.setHorizontalAlignment(AsWingConstants.LEFT);
			
			panelSkillsBase = new JPanel();
			panelSkillsBase.setLocation(new IntPoint(55, 188));
			panelSkillsBase.setSize(new IntDimension(218, 42));
			panelSkillsBase.setPreferredSize(new IntDimension(218, 42));
			var layout5:GridLayout = new GridLayout();
			layout5.setRows(1);
			layout5.setColumns(5);
			layout5.setHgap(2);
			layout5.setVgap(0);
			panelSkillsBase.setLayout(layout5);
			
			panelSkillsControl = new JPanel();
			panelSkillsControl.setLocation(new IntPoint(55, 232));
			panelSkillsControl.setSize(new IntDimension(218, 42));
			panelSkillsControl.setPreferredSize(new IntDimension(218, 42));
			var layout6:GridLayout = new GridLayout();
			layout6.setRows(1);
			layout6.setColumns(5);
			layout6.setHgap(2);
			layout6.setVgap(0);
			panelSkillsControl.setLayout(layout6);
			
			panelSkillsAttack = new JPanel();
			panelSkillsAttack.setLocation(new IntPoint(55, 276));
			panelSkillsAttack.setSize(new IntDimension(218, 42));
			panelSkillsAttack.setPreferredSize(new IntDimension(218, 42));
			var layout7:GridLayout = new GridLayout();
			layout7.setRows(1);
			layout7.setColumns(5);
			layout7.setHgap(2);
			layout7.setVgap(0);
			panelSkillsAttack.setLayout(layout7);
			
			panelSkillsAssist = new JPanel();
			panelSkillsAssist.setLocation(new IntPoint(55, 320));
			panelSkillsAssist.setSize(new IntDimension(218, 42));
			panelSkillsAssist.setPreferredSize(new IntDimension(218, 42));
			var layout8:GridLayout = new GridLayout();
			layout8.setRows(1);
			layout8.setColumns(5);
			layout8.setHgap(2);
			layout8.setVgap(0);
			panelSkillsAssist.setLayout(layout8);
			
			panel68 = new JPanel();
			panel68.setLocation(new IntPoint(0, 366));
			panel68.setSize(new IntDimension(295, 24));
			panel68.setPreferredSize(new IntDimension(295, 24));
			var layout9:FlowLayout = new FlowLayout();
			layout9.setAlignment(AsWingConstants.RIGHT);
			layout9.setHgap(5);
			layout9.setVgap(0);
			panel68.setLayout(layout9);
			
			btn_battle_setting_cancel = new JButton();
			btn_battle_setting_cancel.setSize(new IntDimension(43, 24));
			btn_battle_setting_cancel.setPreferredSize(new IntDimension(43, 24));
			btn_battle_setting_cancel.setText("label");
			
			btn_battle_setting_apply = new JButton();
			btn_battle_setting_apply.setLocation(new IntPoint(230, 0));
			btn_battle_setting_apply.setSize(new IntDimension(43, 24));
			btn_battle_setting_apply.setPreferredSize(new IntDimension(43, 24));
			btn_battle_setting_apply.setText("label");
			
			btn_battle_setting_advanced = new JButton();
			btn_battle_setting_advanced.setLocation(new IntPoint(230, 0));
			btn_battle_setting_advanced.setSize(new IntDimension(43, 24));
			btn_battle_setting_advanced.setPreferredSize(new IntDimension(43, 24));
			btn_battle_setting_advanced.setText("label");
			
			//component layoution
			getContentPane().append(panelTop);
			getContentPane().append(comboItems);
			getContentPane().append(labelOperation);
			getContentPane().append(labelInfo);
			getContentPane().append(panelOperations);
			getContentPane().append(labelOperationSoul);
			getContentPane().append(panelOperationsSoul);
			getContentPane().append(labelSkills);
			getContentPane().append(panelSkillsBase);
			getContentPane().append(panelSkillsControl);
			getContentPane().append(panelSkillsAttack);
			getContentPane().append(panelSkillsAssist);
			getContentPane().append(panel68);
			
			panelTop.append(panelTabs);
			
			panelTabs.append(btn_battle_setting_tab_char);
			panelTabs.append(btn_battle_setting_tab_slave);
			panelTabs.append(btn_battle_setting_tab_lover);
			panelTabs.append(btn_battle_setting_tab_pet);
			panelTabs.append(btn_battle_setting_tab_team);
			
			panel68.append(btn_battle_setting_cancel);
			panel68.append(btn_battle_setting_apply);
			panel68.append(btn_battle_setting_advanced);
			
			
			pack();
			setLocationXY((Engine.W - width) / 2,(Engine.H - height)/2);
			setImages();
			update();
			panelTop.setClipMasked(false);
		}
		private var groupTabs:ButtonGroup = new ButtonGroup();
		public function setImages():void
		{
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);
			
			labelInfo.setFont(new ASFont("宋体", 14, false, false, false, false));
			labelInfo.setForeground(ASColor.YELLOW);
			labelInfo.setTextFilters(new Array(filter));
			
			labelOperation.setFont(font);
			labelOperation.setForeground(ASColor.GREEN);
			labelOperation.setTextFilters(new Array(filter));
			
			labelOperationSoul.setFont(font);
			labelOperationSoul.setForeground(ASColor.HALO_BLUE);
			labelOperationSoul.setTextFilters(new Array(filter));
			
			labelSkills.setFont(font);
			labelSkills.setForeground(ASColor.WHITE);
			labelSkills.setTextFilters(new Array(filter));
			
			
			var img_char_background:DisplayObject = Client.getUIElement("img_battle_setting_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSize(new IntDimension(img_char_background.width, img_char_background.height));
			setPreferredSize(new IntDimension(img_char_background.width, img_char_background.height));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - img_char_background.width)/2,(Engine.H - img_char_background.height)/2);
			
			btn_battle_setting_tab_char.setSelected(true);
			btn_battle_setting_tab_char.wrapSimpleButton(Client.getUIElement("btn_battle_setting_tab_char") as SimpleButton);
			btn_battle_setting_tab_char.setText("");
			btn_battle_setting_tab_slave.wrapSimpleButton(Client.getUIElement("btn_battle_setting_tab_slave") as SimpleButton);
			btn_battle_setting_tab_slave.setText("");
			btn_battle_setting_tab_lover.wrapSimpleButton(Client.getUIElement("btn_battle_setting_tab_lover") as SimpleButton);
			btn_battle_setting_tab_lover.setText("");
			btn_battle_setting_tab_pet.wrapSimpleButton(Client.getUIElement("btn_battle_setting_tab_pet") as SimpleButton);
			btn_battle_setting_tab_pet.setText("");
			btn_battle_setting_tab_team.wrapSimpleButton(Client.getUIElement("btn_battle_setting_tab_team") as SimpleButton);
			btn_battle_setting_tab_team.setText("");
			
			btn_battle_setting_tab_char.setSelected(true);
			groupTabs.appendAll(btn_battle_setting_tab_char,btn_battle_setting_tab_slave,btn_battle_setting_tab_lover
				,btn_battle_setting_tab_pet,btn_battle_setting_tab_team);
			
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			
			btn_battle_setting_cancel.wrapSimpleButton(Client.getUIElement("btn_battle_setting_cancel") as SimpleButton);
			btn_battle_setting_apply.wrapSimpleButton(Client.getUIElement("btn_battle_setting_apply") as SimpleButton);
			btn_battle_setting_advanced.wrapSimpleButton(Client.getUIElement("btn_battle_setting_advanced") as SimpleButton);
			btn_battle_setting_cancel.setText("");
			btn_battle_setting_apply.setText("");
			btn_battle_setting_advanced.setText("");
			
			btn_battle_setting_advanced.setEnabled(false);
			
			panelOperationsSoul.setClipMasked(false);
			panelOperations.setClipMasked(false);
			var nIndex:uint = 0;
			var item:PanelSkill = null;
			for(var i:int = 0; i < 6; i++)
			{
				item = new PanelSkill;
				panelOperations.append(item);
				_panelsOperation[nIndex] = item;
				setSkillPanel(item,nIndex);
				item.index = nIndex;
				item.addEventListener(ClickCountEvent.CLICK_COUNT, onOperationClickCount); 
				
				item = new PanelSkill;
				panelOperationsSoul.append(item);
				_panelsOperationSoul[nIndex] = item;
				setSkillPanel(item,nIndex);
				item.index = nIndex;
				item.addEventListener(ClickCountEvent.CLICK_COUNT, onOperationSoulClickCount); 
				
				nIndex++;
			}
			
			panelSkillsBase.setClipMasked(false);
			panelSkillsControl.setClipMasked(false);
			panelSkillsAttack.setClipMasked(false);
			panelSkillsAssist.setClipMasked(false);
			nIndex = 0;
			for(i = 0; i < 5; i++)
			{
				item = new PanelSkill;
				item.setPreferredSize(new IntDimension(42,42));
				panelSkillsBase.append(item);
				_panelsSkillsBase[nIndex] = item;
				setSkillPanel(item,nIndex);
				item.index = nIndex;
				item.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillsClickCount); 
				
				item = new PanelSkill;
				item.setPreferredSize(new IntDimension(42,42));
				panelSkillsControl.append(item);
				_panelsSkillsControl[nIndex] = item;
				setSkillPanel(item,nIndex);
				item.index = nIndex;
				item.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillsClickCount); 
				
				item = new PanelSkill;
				item.setPreferredSize(new IntDimension(42,42));
				panelSkillsAttack.append(item);
				_panelsSkillsAttack[nIndex] = item;
				setSkillPanel(item,nIndex);
				item.index = nIndex;
				item.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillsClickCount); 
				
				item = new PanelSkill;
				item.setPreferredSize(new IntDimension(42,42));
				panelSkillsAssist.append(item);
				_panelsSkillsAssist[nIndex] = item;
				setSkillPanel(item,nIndex);
				item.index = nIndex;
				item.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillsClickCount); 
				
				nIndex++;
			}
			
			btn_battle_setting_cancel.addActionListener(onBtnCancel);
			btn_battle_setting_apply.addActionListener(onBtnApply);
			
			var listModel:VectorListModel  = new VectorListModel;
			listModel.append(new ComboBoxItem(0,0,"tao0"));
			listModel.append(new ComboBoxItem(1,0,"tao1"));
			listModel.append(new ComboBoxItem(2,0,"tao2"));
			listModel.append(new ComboBoxItem(3,0,"tao3"));
			listModel.append(new ComboBoxItem(4,0,"tao4"));
			//comboItems.setOpaque(false);
			comboItems.setModel(listModel);
			comboItems.getEditor().setEditable(false);
			comboItems.setForeground(ASColor.ORANGE);
			//comboItems.setBackground(new ASColor(0x033332,1.0));
			//comboItems.setBackground(ASColor.GRAY);
			comboItems.setFont(font);
			comboItems.setBackgroundDecorator(null);
			comboItems.getPopupList().setBackgroundDecorator(null);
			comboItems.getPopupList().setBackground(new ASColor(0x011111,1.0));
			comboItems.getPopupList().setForeground(ASColor.ORANGE);
			comboItems.getPopupList().setBorder(new EmptyBorder);
			comboItems.getPopupList().setOpaque(false);
			comboItems.setBorder(new EmptyBorder);
			comboItems.pack();
			comboItems.paintImmediately();
			comboItems.setVisible(false);
			//comboItems.setAlignmentX(-1);
			
			comboItems.addActionListener(onSelected);
			
			btn_battle_setting_tab_char.addActionListener(onBtnTabChar);
			btn_battle_setting_tab_slave.addActionListener(onBtnTabSlave);
			btn_battle_setting_tab_lover.addActionListener(onBtnTabLover);
			btn_battle_setting_tab_pet.addActionListener(onBtnTabPet);
			btn_battle_setting_tab_team.addActionListener(onBtnTabTeam);
			
			labelInfo.setText("只可设计元神队伍成员的自动战斗设置");
			
			addEventListener(FrameEvent.FRAME_CLOSING,onFrameClosing);
			addEventListener(AWEvent.HIDDEN,onFrameClosing);
		}
		private function onBtnTabChar(e:Event):void
		{
			groupTabs.setSelected(btn_battle_setting_tab_char.getModel(),true);
			battleSettingType = BATTLE_SETTING_TYPE_CHAR;
			selectIndex = 0;
			bPartner = 0;
			comboItems.setVisible(false);
			labelOperation.setVisible(true);
			panelOperations.setVisible(true);
			labelInfo.setVisible(false);
			m_szCharName = CharInfo.charName;
			update();
		}
		private function onBtnTabSlave(e:Event):void
		{
			battleSettingType = BATTLE_SETTING_TYPE_SLAVE;
			selectIndex = 0;
			bPartner = 0;
			comboItems.setVisible(true);
			labelOperation.setVisible(true);
			panelOperations.setVisible(true);
			labelInfo.setVisible(false);
			var listModel:VectorListModel  = new VectorListModel;
			var nIndex:int = 0;
			for each(var obj:Object in CharInfo.m_arSlaves)
			{
				if(nIndex == 0)	m_szCharName = obj.m_szCharName;
				listModel.append(new ComboBoxItem(nIndex++,0,obj.m_szCharName));
			}
			comboItems.setModel(listModel);
			if(comboItems.getModel().getSize() > 0)
				comboItems.setSelectedIndex(selectIndex);
			update();
		}
		private function onBtnTabLover(e:Event):void
		{
			battleSettingType = BATTLE_SETTING_TYPE_LOVER;
			selectIndex = 0;
			bPartner = 0;
			comboItems.setVisible(false);
			labelOperation.setVisible(true);
			panelOperations.setVisible(true);
			labelInfo.setVisible(false);
			m_szCharName = '';
			//var listModel:VectorListModel  = new VectorListModel;
			var nIndex:int = 0;

			var obj:Object = CharInfo.objLover;
			if(obj.m_nCharId != 0)
			{
				m_szCharName = obj.m_szCharName;
			}
			//listModel.append(new ComboBoxItem(nIndex++,0,obj.m_szCharName));
			
			//comboItems.setModel(listModel);
			//comboItems.setSelectedIndex(selectIndex);
			
			update();
		}
		private function onBtnTabPet(e:Event):void
		{
			battleSettingType = BATTLE_SETTING_TYPE_PET;
			selectIndex = 0;
			bPartner = 0;
			comboItems.setVisible(true);
			labelOperation.setVisible(true);
			panelOperations.setVisible(true);
			labelInfo.setVisible(false);
			
			var listModel:VectorListModel  = new VectorListModel;
			var nIndex:int = 0;
			for each(var obj:Object in CharInfo.m_arPets)
			{
				if(nIndex == 0)	m_szCharName = obj.m_szCharName;
				listModel.append(new ComboBoxItem(nIndex++,0,obj.m_szCharName+' Lv.'+obj.m_nLevel));
			}
			comboItems.setModel(listModel);
			if(comboItems.getModel().getSize() > 0)
				comboItems.setSelectedIndex(selectIndex);
			
			update();
		}
		private function onBtnTabTeam(e:Event):void
		{
			battleSettingType = BATTLE_SETTING_TYPE_TEAMMATE;
			selectIndex = 0;
			bPartner = 0;
			comboItems.setVisible(true);
			labelOperation.setVisible(false);
			panelOperations.setVisible(false);
			labelInfo.setVisible(true);
			
			if(CharInfo.m_arTeamSoulMembers == null)
				CharInfo.m_arTeamSoulMembers = [];
			
			var listModel:VectorListModel  = new VectorListModel;
			var nIndex:int = 0;
			for each(var obj:Object in CharInfo.m_arTeamSoulMembers)
			{
				if(nIndex == 0) 
				{
					nIndex++;
					continue;
				}
				if(nIndex == 1)	m_szCharName = obj.m_szCharName;
				listModel.append(new ComboBoxItem(nIndex,0,obj.m_szCharName));
				
				if(obj.objPartner.m_nSoulType != Const.SOUL_TYPE_NULL)
				{
					var str:String = '';
					if(obj.objPartner.m_nSoulType == Const.SOUL_TYPE_SLAVE)
						str = obj.m_szCharName + '的奴隶';
					if(obj.objPartner.m_nSoulType == Const.SOUL_TYPE_LOVER)
						str = obj.m_szCharName + '的情人';
					if(obj.objPartner.m_nSoulType == Const.SOUL_TYPE_PET)
						str = obj.m_szCharName + '的宠物';
					listModel.append(new ComboBoxItem(nIndex,1,str));
				}
				nIndex++
			}
			comboItems.setModel(listModel);
			if(comboItems.getModel().getSize() > 0)
				comboItems.setSelectedIndex(selectIndex);
			
			update();
		}
		private function onBtnCancel(e:Event):void
		{
			//this.closeReleased();
			update();
			var skill_id:int = 0;
			arAutoBattleSkills.splice(0,arAutoBattleSkills.length);
			for each(skill_id in skillsAuto)
			{
				arAutoBattleSkills.push(skill_id);
			}
			arAutoBattleSkillsSoul.splice(0,arAutoBattleSkills.length);
			for each(skill_id in skillsAutoSoul)
			{
				arAutoBattleSkillsSoul.push(skill_id);
			}
			btn_battle_setting_cancel.setEnabled(isModify());
			btn_battle_setting_apply.setEnabled(isModify());
		}

		
		private function onBtnApply(e:Event):void
		{
			CharInfo.m_nBattleMode = 0;
			FrameBattleAuto.update();
			
			var skill:int = 0;
			
			skillsAuto.splice(0,skillsAuto.length);
			skillsAutoSoul.splice(0,skillsAutoSoul.length);
			
			for each(skill in arAutoBattleSkills)
			{
				skillsAuto.push(skill);
			}
			for each(skill in arAutoBattleSkillsSoul)
			{
				skillsAutoSoul.push(skill);
			}
			
			var array:Array = new Array();
			array.push(battleSettingType);
			array.push(battleSettingType == BATTLE_SETTING_TYPE_TEAMMATE ? selectIndex-1:selectIndex);
			array.push(bPartner);
			array.push(CharInfo.m_nBattleMode);
			var item:uint = 0;
			for each(item in skillsAuto)
			{
				array.push(item);
			}
			for each(item in skillsAutoSoul)
			{
				array.push(item);
			}
			Client.getInstance().sendPacketLogic(320,array);
			btn_battle_setting_cancel.setEnabled(isModify());
			btn_battle_setting_apply.setEnabled(isModify());
		}
		private function setSkillPanel(item:PanelSkill,nIndex:int):void
		{
			//item.addEventListener(ClickCountEvent.CLICK_COUNT, onSkillClickCount);  
			item.setDragEnabled(true);
			item.addEventListener(DragAndDropEvent.DRAG_RECOGNIZED, onDragRecognized);
			
			item.setDropTrigger(true);
			item.setDragAcceptableInitiatorAppraiser(onDropAppraiser);
			item.addEventListener(DragAndDropEvent.DRAG_ENTER, onDragEnter);
			item.addEventListener(DragAndDropEvent.DRAG_EXIT, onDragExit);
			item.addEventListener(DragAndDropEvent.DRAG_DROP, onDragDrop);
			
			//item.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
			//item.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
			item.setBorder(new EmptyBorder());
			item.index = nIndex;
			
		}
		static public  function phBattleSetting_320(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phBattleSetting_320", msg);
			var nIndex:uint = 0;
			CharInfo.m_nBattleMode = msg[nIndex++];
			for(var i:int = 0; i < 6; i++)
				CharInfo.m_arAutoBattleSkills[i] = msg[nIndex++];
			for(i = 0; i < 6; i++)
				CharInfo.m_arAutoBattleSkillsSoul[i] = msg[nIndex++];
			FrameBattleAuto.update();
			if(FrameBattleSetting.isShowing())
				FrameBattleSetting._frame.update();
		}
		
		public static function getSkillsByType(skillsArray:Array,typeArray:Array):Array
		{
			var retArray:Array = [];
			
			for each(var obj:Object in skillsArray)
			{
				if(obj.csv_id == 0)
				{
					continue;
				}
				var objSkillCSV:Object = Client.getInstance().GetSkillCSV(obj.csv_id);
				if(objSkillCSV == null)
				{
					continue;
				}
				if(typeArray.indexOf(int(objSkillCSV.type)) != -1)
					retArray.push(obj);
			}
			return retArray;
		}
		public function isModify():Boolean
		{
			if(skillsAuto == null || skillsAuto.length == 0) return false;
			if(arAutoBattleSkills == null || arAutoBattleSkills.length == 0) return false;
			if(skillsAutoSoul == null || skillsAutoSoul.length == 0) return false;
			if(arAutoBattleSkillsSoul == null || arAutoBattleSkillsSoul.length == 0) return false;
			
			for(var i:int; i < 6; i++)
			{
				if(skillsAuto[i] != arAutoBattleSkills[i])
					return true;
				if(skillsAutoSoul[i] != arAutoBattleSkillsSoul[i])
					return true;
			}
			return false;
		}
		public static var BATTLE_SETTING_TYPE_CHAR:int = 0;
		public static var BATTLE_SETTING_TYPE_SLAVE:int = 1;
		public static var BATTLE_SETTING_TYPE_LOVER:int = 2;
		public static var BATTLE_SETTING_TYPE_PET:int = 3;
		public static var BATTLE_SETTING_TYPE_TEAMMATE:int = 4;
		public static var BATTLE_SETTING_TYPE_ALL:int = 5;
		
		public var m_szCharName:String = '';
		public var battleSettingType:int = BATTLE_SETTING_TYPE_CHAR;
		public var uniqueSettingType:int = BATTLE_SETTING_TYPE_ALL;
		public var selectIndex:int = 0;
		public var bPartner:int = 0;
		public var skillsBase:Array = null;
		public var skillsAuto:Array = null;
		public var skillsAutoSoul:Array = null;
		public function update():void
		{
			panelTabs.removeAll();
			var needSelectChar:Boolean = false;
			if(uniqueSettingType == BATTLE_SETTING_TYPE_ALL)
			{
				panelTabs.append(btn_battle_setting_tab_char);
				
				if(CharInfo.m_arSlaves.length > 0)
					panelTabs.append(btn_battle_setting_tab_slave);
				else if(battleSettingType == BATTLE_SETTING_TYPE_SLAVE)
					needSelectChar = true;
				
				if(CharInfo.objLover != null && CharInfo.objLover.m_nCharId != 0)
					panelTabs.append(btn_battle_setting_tab_lover);
				else if(battleSettingType == BATTLE_SETTING_TYPE_LOVER)
					needSelectChar = true;
				
				if(CharInfo.m_arPets.length > 0)
					panelTabs.append(btn_battle_setting_tab_pet);
				else if(battleSettingType == BATTLE_SETTING_TYPE_PET)
					needSelectChar = true;
				
				if(CharInfo.m_arTeamSoulMembers.length > 1)
					panelTabs.append(btn_battle_setting_tab_team);
				else if(battleSettingType == BATTLE_SETTING_TYPE_TEAMMATE)
					needSelectChar = true;
				
				if(needSelectChar)
				{
					battleSettingType = BATTLE_SETTING_TYPE_CHAR;
					selectIndex = 0;
					bPartner = 0;
					comboItems.setVisible(false);
					labelOperation.setVisible(true);
					panelOperations.setVisible(true);
					labelInfo.setVisible(false);
					m_szCharName = CharInfo.charName;
					groupTabs.setSelected(btn_battle_setting_tab_char.getModel(),true);
				}
			}
			else
			{
				battleSettingType = uniqueSettingType;
				if(battleSettingType == BATTLE_SETTING_TYPE_SLAVE)
				{
					if(CharInfo.m_arSlaves.length > 0)
					{
						panelTabs.append(btn_battle_setting_tab_slave);
						groupTabs.setSelected(btn_battle_setting_tab_slave.getModel(),true);
						//onBtnTabSlave(null);
					}
					else
						needSelectChar = true;
				}
				if(battleSettingType == BATTLE_SETTING_TYPE_LOVER)
				{
					if(CharInfo.objLover != null && CharInfo.objLover.m_nCharId != 0)
					{
						panelTabs.append(btn_battle_setting_tab_lover);
						groupTabs.setSelected(btn_battle_setting_tab_lover.getModel(),true);
						//onBtnTabLover(null);
					}
					else
						needSelectChar = true;
				}
				if(battleSettingType == BATTLE_SETTING_TYPE_PET)
				{
					if(CharInfo.m_arPets.length > 0)
					{
						panelTabs.append(btn_battle_setting_tab_pet);
						groupTabs.setSelected(btn_battle_setting_tab_pet.getModel(),true);
						//onBtnTabPet(null);
					}
					else
						needSelectChar = true;
				}
				if(battleSettingType == BATTLE_SETTING_TYPE_TEAMMATE)
				{
					if(CharInfo.m_arTeamSoulMembers.length > 1)
					{
						panelTabs.append(btn_battle_setting_tab_team);
						groupTabs.setSelected(btn_battle_setting_tab_team.getModel(),true);
						//onBtnTabTeam(null);
					}
					else
						needSelectChar = true;
				}
				if(needSelectChar)
				{
					panelTabs.append(btn_battle_setting_tab_char);
					
					battleSettingType = BATTLE_SETTING_TYPE_CHAR;
					selectIndex = 0;
					bPartner = 0;
					comboItems.setVisible(false);
					labelOperation.setVisible(true);
					panelOperations.setVisible(true);
					labelInfo.setVisible(false);
					m_szCharName = CharInfo.charName;
					groupTabs.setSelected(btn_battle_setting_tab_char.getModel(),true);
				}
			}
			
			panelTabs.pack();
			revalidate();
			var nIndex:uint = 0;
			var item:Object = null;
			var objSkillCSV:Object = null;
			var skill:PanelSkill = null;
			
			skillsBase = null;
			skillsAuto = null;
			skillsAutoSoul = null;
			var obj:Object = null;
			if(battleSettingType == BATTLE_SETTING_TYPE_CHAR)
			{
				skillsBase = CharInfo.m_arSkills;
				skillsAuto = CharInfo.m_arAutoBattleSkills;
				skillsAutoSoul = CharInfo.m_arAutoBattleSkillsSoul;
				m_szCharName = CharInfo.charName;
			}
			if(battleSettingType == BATTLE_SETTING_TYPE_SLAVE)
			{
				if(selectIndex >= CharInfo.m_arSlaves.length)
					selectIndex = 0;
				obj = CharInfo.m_arSlaves[selectIndex];
				if(obj != null)
				{
					skillsBase = obj.m_arSkills;
					skillsAuto = obj.m_arAutoBattleSkills;
					skillsAutoSoul = obj.m_arAutoBattleSkillsSoul;	
				}
			}
			if(battleSettingType == BATTLE_SETTING_TYPE_LOVER)
			{
				obj = CharInfo.objLover;
				if(obj != null)
				{
					skillsBase = obj.m_arSkills;
					skillsAuto = obj.m_arAutoBattleSkills;
					skillsAutoSoul = obj.m_arAutoBattleSkillsSoul;
				}
			}
			if(battleSettingType == BATTLE_SETTING_TYPE_PET)
			{
				if(selectIndex >= CharInfo.m_arPets.length)
					selectIndex = 0;
				obj = CharInfo.m_arPets[selectIndex];
				if(obj != null)
				{
					skillsBase = obj.m_arSkills;
					skillsAuto = obj.m_arAutoBattleSkills;
					skillsAutoSoul = obj.m_arAutoBattleSkillsSoul;	
				}
			}
			
			if(battleSettingType == BATTLE_SETTING_TYPE_TEAMMATE)
			{
				if(CharInfo.m_arTeamSoulMembers == null)
					CharInfo.m_arTeamSoulMembers = [];
				if(selectIndex >= CharInfo.m_arTeamSoulMembers.length)
					selectIndex = 0;
				obj = bPartner == 0 ? CharInfo.m_arTeamSoulMembers[selectIndex] : CharInfo.m_arTeamSoulMembers[selectIndex].objPartner;
				if(obj != null)
				{
					skillsBase = obj.m_arSkills;
					skillsAuto = obj.m_arAutoBattleSkills;
					skillsAutoSoul = obj.m_arAutoBattleSkillsSoul;	
				}
			}
			
			for each(skill in _panelsOperation)skill.item = null;
			for each(skill in _panelsOperationSoul)skill.item = null;
			for each(skill in _panelsSkillsBase)skill.item = null;
			for each(skill in _panelsSkillsControl)skill.item = null;
			for each(skill in _panelsSkillsAttack)skill.item = null;
			for each(skill in _panelsSkillsAssist)skill.item = null;

			
			var array:Array = getSkillsByType(skillsBase,[1,2,3,4,5]);
			for each(item in array)
			{
				_panelsSkillsBase[nIndex].item = item;
				nIndex++;
				if(nIndex >= 5)
					break;
			}
			
			nIndex = 0;
			array = getSkillsByType(skillsBase,[6,7,8]);
			for each(item in array)
			{
				_panelsSkillsControl[nIndex].item = item;
				nIndex++;
				if(nIndex >= 5)
					break;
			}
			
			nIndex = 0;
			array = getSkillsByType(skillsBase,[9,10,11]);
			for each(item in array)
			{
				_panelsSkillsAttack[nIndex].item = item;
				nIndex++;
				if(nIndex >= 5)
					break;
			}
			
			nIndex = 0;
			array = getSkillsByType(skillsBase,[12,13,14]);
			for each(item in array)
			{
				_panelsSkillsAssist[nIndex].item = item;
				nIndex++;
				if(nIndex >= 5)
					break;
			}
			
			var csv_id:int = 0;
			nIndex = 0;
			for each(csv_id in skillsAuto)
			{
				item = CharInfo.getSkillObjectBySkillCSVId(skillsBase,csv_id);
				
				_panelsOperation[nIndex].item = item;
				nIndex++;
				if(nIndex >= 6)
					break;
			}
			
			csv_id = 0;
			nIndex = 0;
			for each(csv_id in skillsAutoSoul)
			{
				item = CharInfo.getSkillObjectBySkillCSVId(skillsBase,csv_id);
				
				_panelsOperationSoul[nIndex].item = item;
				nIndex++;
				if(nIndex >= 6)
					break;
			}
			
			var skill_id:int = 0;
			arAutoBattleSkills.splice(0,arAutoBattleSkills.length);
			for each(skill_id in skillsAuto)
			{
				arAutoBattleSkills.push(skill_id);
			}
			
			arAutoBattleSkillsSoul.splice(0,arAutoBattleSkillsSoul.length);
			for each(skill_id in skillsAutoSoul)
			{
				arAutoBattleSkillsSoul.push(skill_id);
			}
			
			labelOperation.setText(m_szCharName+" 操作序列:");
			labelOperationSoul.setText(m_szCharName+" 操作序列(元神):");
			labelSkills.setText(m_szCharName+" 可用技能:");
			btn_battle_setting_cancel.setEnabled(isModify());
			btn_battle_setting_apply.setEnabled(isModify());
			
		}
		
		private function onSelected(event:Event):void
		{
			//trace(comboItems.getSelectedItem().id + comboItems.getSelectedItem().name);
			//trace(comboItems.getSelectedItem());
			
			var item:ComboBoxItem = comboItems.getSelectedItem();
			if(item == null)
				return;
			if(item.name != null)
				m_szCharName = item.name;
			labelOperation.setText(m_szCharName+" 操作序列:");
			labelOperationSoul.setText(m_szCharName+" 操作序列(元神):");
			labelSkills.setText(m_szCharName+" 可用技能:");
			selectIndex = item.index;
			bPartner = item.bPartner;
			update();
		}
		
		//是否接受这个被拖入的组件
		private function onDropAppraiser(initiator:JPanel):Boolean
		{
			return true;
		}
		//被接受的组件被拖入时，改变Panel背景色
		private function onDragEnter(e:DragAndDropEvent):void
		{
			var initiator:PanelSkill = e.getDragInitiator() as PanelSkill;
			if(onDropAppraiser(initiator))
			{
				if(e.target is PanelSkill)
				{
					var target:PanelSkill = e.target as PanelSkill;
					target.setBorder(new LineBorder(null,ASColor.GREEN));
				}
			}
		}
		
		//组件被拖出时，恢复原来的背景色
		private function onDragExit(e:DragAndDropEvent):void
		{
			if(e.target is PanelSkill)
			{
				var target:JPanel = e.target as JPanel;
				target.setBorder(new EmptyBorder());
			}
		}
		//组件被释放时，如果是被接受的，那么把它加入此面板
		private function onDragDrop(event:DragAndDropEvent):void
		{
			var initiator:PanelSkill = event.getDragInitiator() as PanelSkill;
			var target:PanelSkill = event.target as PanelSkill;
			if(target == null) return;
			target.setBorder(new EmptyBorder());
			if(!onDropAppraiser(initiator)) return;
			
			var arrayInitiator:Array = null;
			if(_panelsSkillsBase.indexOf(initiator) != -1 ) arrayInitiator = _panelsSkillsBase;
			if(_panelsSkillsControl.indexOf(initiator) != -1 ) arrayInitiator = _panelsSkillsControl;
			if(_panelsSkillsAttack.indexOf(initiator) != -1 ) arrayInitiator = _panelsSkillsAttack;
			if(_panelsSkillsAssist.indexOf(initiator) != -1 ) arrayInitiator = _panelsSkillsAssist;
			
			var arrayTarget:Array = null;
			if(_panelsSkillsBase.indexOf(target) != -1 ) arrayTarget = _panelsSkillsBase;
			if(_panelsSkillsControl.indexOf(target) != -1 ) arrayTarget = _panelsSkillsControl;
			if(_panelsSkillsAttack.indexOf(target) != -1 ) arrayTarget = _panelsSkillsAttack;
			if(_panelsSkillsAssist.indexOf(target) != -1 ) arrayTarget = _panelsSkillsAssist;
			
			//从人物技能栏拖到人物操作技能栏
			if(arrayInitiator != null && _panelsOperation.indexOf(target) != -1)
			{
				arAutoBattleSkills[target.index] = arrayInitiator[initiator.index].item.csv_id;
				_panelsOperation[target.index].item = arrayInitiator[initiator.index].item;
			}
			
			//从人物技能栏拖到人物元神操作技能栏
			if(arrayInitiator != null  && _panelsOperationSoul.indexOf(target) != -1)
			{
				arAutoBattleSkillsSoul[target.index] = arrayInitiator[initiator.index].item.csv_id;
				_panelsOperationSoul[target.index].item = arrayInitiator[initiator.index].item;
			}
			
			//从人物操作技能栏拖到人物技能栏
			if(arrayTarget != null  && _panelsOperation.indexOf(initiator) != -1)
			{
				arAutoBattleSkills[initiator.index] = 0;
				_panelsOperation[initiator.index].item = null;
			}
			
			//从人物操作技能栏拖到人物技能栏
			if(arrayTarget != null  && _panelsOperationSoul.indexOf(initiator) != -1)
			{
				arAutoBattleSkillsSoul[initiator.index] = 0;
				_panelsOperationSoul[initiator.index].item = null;
			}
			btn_battle_setting_cancel.setEnabled(isModify());
			btn_battle_setting_apply.setEnabled(isModify());
		}
		/**
		 * 监听到dragBtn的ON_DRAG_RECOGNIZED事件，将拖拽事件托管给DragManager。
		 * @param dragInitiator          此例中是指dragBtn。
		 * @param touchedChild    被鼠标拖住的组件，此例中亦是dragBtn。
		 */
		
		//private var _currentIndex:uint = 0;
		private function onDragRecognized( e:DragAndDropEvent):void
		{
			var btn:PanelSkill = e.target as PanelSkill;
			if(btn.icon_id <= 0)
				return;
			DragManager.startDrag(btn,new SourceData("item", btn.getToolTipText()),new DraggingImageSkill(btn)); 
		}
		private function onOperationClickCount(event:ClickCountEvent):void
		{   
			var target:PanelSkill = event.target as PanelSkill;
			if(target == null) return;
			if(event.getCount() >= 2)
			{   
				arAutoBattleSkills[target.index] = 0;
				_panelsOperation[target.index].item = null;
			}   
			btn_battle_setting_cancel.setEnabled(isModify());
			btn_battle_setting_apply.setEnabled(isModify());
		}
		private function onOperationSoulClickCount(event:ClickCountEvent):void
		{   
			var target:PanelSkill = event.target as PanelSkill;
			if(target == null) return;
			if(event.getCount() >= 2)
			{   
				arAutoBattleSkillsSoul[target.index] = 0;
				_panelsOperationSoul[target.index].item = null;
			}  
			btn_battle_setting_cancel.setEnabled(isModify());
			btn_battle_setting_apply.setEnabled(isModify());
		}
		private function onSkillsClickCount(event:ClickCountEvent):void
		{   
			var target:PanelSkill = event.target as PanelSkill;
			if(target == null) return;
			if(event.getCount() >= 2)
			{   
				var array:Array = null;
				if(_panelsSkillsBase.indexOf(target) != -1 ) array = _panelsSkillsBase;
				if(_panelsSkillsControl.indexOf(target) != -1 ) array = _panelsSkillsControl;
				if(_panelsSkillsAttack.indexOf(target) != -1 ) array = _panelsSkillsAttack;
				if(_panelsSkillsAssist.indexOf(target) != -1 ) array = _panelsSkillsAssist;
				
				var index:int = 0;
				for(var i:int = 0; i < 6; i++)
				{
					if(battleSettingType != BATTLE_SETTING_TYPE_TEAMMATE && _panelsOperation[i].item == null)
					{
						index = _panelsOperation[i].index;
						if(array[target.index].item == null)
							continue;
						arAutoBattleSkills[index] = array[target.index].item.csv_id;
						_panelsOperation[index].item = array[target.index].item;
						btn_battle_setting_cancel.setEnabled(isModify());
						btn_battle_setting_apply.setEnabled(isModify());
						return;
					}
				}
				
				for(i = 0; i < 6; i++)
				{
					if(_panelsOperationSoul[i].item == null)
					{
						index = _panelsOperationSoul[i].index;
						if(array[target.index].item == null)
							continue;
						arAutoBattleSkillsSoul[index] = array[target.index].item.csv_id;
						_panelsOperationSoul[index].item = array[target.index].item;
						btn_battle_setting_cancel.setEnabled(isModify());
						btn_battle_setting_apply.setEnabled(isModify());
						return;
					}
				}
			}   
			
		}
		
		public static function onFrameClosing(e:Event):void
		{
			if(_frameParent == null)
				return;
			var teamDestX:int = (Engine.W - _frameParent.width)/2;
			var teamDestY:int = (Engine.H - _frameParent.height)/2;
			var tween:TweenLite = TweenLite.to(_frameParent, 0.3, {x:teamDestX, y:teamDestY});
			_frameParent = null;
		}
		public static function onFrameParentClosing(e:Event):void
		{
			if(_frameParent == null)
				return;
			_frameParent.removeEventListener(FrameEvent.FRAME_CLOSING,onFrameParentClosing);
			_frameParent.removeEventListener(AWEvent.HIDDEN,onFrameParentClosing);
			hide();
		}
		
		public static var _frameParent:JFrame = null;
		public static var _frame:FrameBattleSetting = null;
		public static function show(frameParent:JFrame = null,uniqueType:int = 5):void
		{
			if(isShowing())
			{
				hide()
				return;
			}
			if(_frame == null)
			{
				_frame = new FrameBattleSetting();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			_frame.uniqueSettingType = uniqueType;
			_frame.show();
			PanelMainHelp.getInstance().bringToTop(_frame);
			
			if(uniqueType == BATTLE_SETTING_TYPE_CHAR || uniqueType == BATTLE_SETTING_TYPE_ALL)
			{
				_frame.onBtnTabChar(null);
			}
			if(uniqueType == BATTLE_SETTING_TYPE_SLAVE)
			{
				_frame.onBtnTabSlave(null);
			}
			if(uniqueType == BATTLE_SETTING_TYPE_LOVER)
			{
				_frame.onBtnTabLover(null);
			}
			if(uniqueType == BATTLE_SETTING_TYPE_PET)
			{
				_frame.onBtnTabPet(null);

			}
			if(uniqueType == BATTLE_SETTING_TYPE_TEAMMATE)
			{
				_frame.onBtnTabTeam(null);
			}
			
			//if(!_frame.isShowing())
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
			
			_frameParent = frameParent;
			
			if(_frameParent != null)
			{
				var leftFrame:JFrame = _frameParent;//_frame;
				var rightFrame:JFrame = _frame;
				
				var leftX:int = (Engine.W - (rightFrame.width+leftFrame.width))/2;
				var leftY:int = (Engine.H - leftFrame.height)/2;
				
				var rightX:int = leftX + leftFrame.width;
				var rightY:int = leftY + (leftFrame.height - rightFrame.height)/2;
				
				var tween:TweenLite = TweenLite.to(leftFrame, 0.3, {x:leftX, y:leftY});
				var list_tween:TweenLite = TweenLite.to(rightFrame, 0.3, {x:rightX, y:rightY});
				
				_frameParent.addEventListener(FrameEvent.FRAME_CLOSING,onFrameParentClosing);
				_frameParent.addEventListener(AWEvent.HIDDEN,onFrameParentClosing);
			}
			else
			{
				_frame.setLocationXY((Engine.W - _frame.width) / 2,(Engine.H - _frame.height)/2);
			}
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
	}
}

class ComboBoxItem
{
	private var _index:int;
	private var _bPartner:int;
	private var _name:String;
	
	
	public function ComboBoxItem($index:int, $bPartner:int, $name:String)
	{
		this._index = $index;
		this._bPartner = $bPartner;
		this._name = $name;
	}
	
	public function set index($index:int):void
	{
		this._index= $index;
	}
	
	public function get index():int
	{
		return this._index;
	}
	
	public function set bPartner($bPartner:int):void
	{
		this._bPartner= $bPartner;
	}
	
	public function get bPartner():int
	{
		return this._bPartner;
	}
	
	public function set name($name:String):void
	{
		this._name = $name;
	}
	
	public function get name():String
	{
		return this._name;
	}
	
	
	//注意这里
	public function toString():String
	{
		return this._name;
	}
	
}
